package com.dgut.service.impl;

import com.dgut.dao.IAccountDao;
import com.dgut.domain.Account;
import com.dgut.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("accountService")
public class AccountServiceImpl implements IAccountService {

    @Autowired
    private IAccountDao dao;

    @Override
    @Transactional(readOnly = true)
    public List<Account> findAccounts() {
        return dao.findAccounts();
    }

    @Override
    @Transactional
    public void save() {
        Account account = new Account("xiaoming",100f);
        dao.save(account);

        int i = 1/0;

        Account account1 = new Account("xiaohong",50f);
        dao.save(account1);

    }
}
